import redis


def main():
    client = redis.Redis(host='42.192.52.196', port=6379,
                         password='qwert')
    # print(client)
    client.set('username', 'hellokitty', ex=300)
    print(client.ttl('username'))
    print(client.get('username').decode())
    client.set('nickname', '哈哈')
    print(client.get('nickname').decode())

    # 使用哈希类型
    client.hset('stu1', 'name', '哈哈')
    print(client.hget('stu1', 'name').decode())


if __name__ == '__main__':
    main()
